function log(store) {
    const next = store.dispatch;

    function logAndThunk(action) {
        if (typeof action === 'function') {
            // action是函数的情况
            // 这里的dispatch最好store.dispatch而不是next,防止action内部再次dispatch一个函数
            action(store.dispatch, store.getState)
        } else {
            console.log('当前派发的action:', action)
            next(action)
            console.log('派发action后的state', store.getState())
        }
    }

    // monkey patch => 猴补丁(劫持)
    store.dispatch = logAndThunk
}

export default log